From: Florian Müllner Date: Fri, 29 Jul 2022 18:00:18 +0000 (+0200) Subject: status/powerProfiles: Remember last selected non-default profile X-Git-Tag: archive/raspbian/50.5-1+rpi1~1^2~461^2^2~208 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/%22/%22http:/www.example.com/cgi/%22?a=commitdiff_plain;h=4f155d3757e35f090fdcee2d8f3a0c2c7271512f;p=gnome-shell.git status/powerProfiles: Remember last selected non-default profile When we move to quick settings, this will allow us to toggle between two profiles even where more profiles are available. Part-of: --- diff --git a/data/org.gnome.shell.gschema.xml.in b/data/org.gnome.shell.gschema.xml.in index d3f3c702d..c56a3399e 100644 --- a/data/org.gnome.shell.gschema.xml.in +++ b/data/org.gnome.shell.gschema.xml.in @@ -94,6 +94,15 @@ adapter is ever seen not to have devices associated to it. + + "power-saver" + The last selected non-default power profile + + Some systems support more than two power profiles. In order to still support + toggling between two profiles, this key records the last selected non-default + profile. + + '' The last version the “Welcome to GNOME” dialog was shown for diff --git a/js/ui/status/powerProfiles.js b/js/ui/status/powerProfiles.js index 9878abfac..f9a97a64f 100644 --- a/js/ui/status/powerProfiles.js +++ b/js/ui/status/powerProfiles.js @@ -32,6 +32,8 @@ const PROFILE_PARAMS = { }, }; +const LAST_PROFILE_KEY = 'last-selected-power-profile'; + var Indicator = GObject.registerClass( class Indicator extends PanelMenu.SystemIndicator { _init() { @@ -101,14 +103,19 @@ class Indicator extends PanelMenu.SystemIndicator { if (!this._item.visible) return; + const {ActiveProfile: activeProfile} = this._proxy; + for (const [profile, item] of this._profileItems) { - item.setOrnament(profile === this._proxy.ActiveProfile + item.setOrnament(profile === activeProfile ? PopupMenu.Ornament.CHECK : PopupMenu.Ornament.NONE); } - const {label, iconName} = PROFILE_PARAMS[this._proxy.ActiveProfile]; + const {label, iconName} = PROFILE_PARAMS[activeProfile]; this._item.label.text = label; this._item.icon.icon_name = iconName; + + if (activeProfile !== 'balanced') + global.settings.set_string(LAST_PROFILE_KEY, activeProfile); } });